package com.posti.core.geocoding;

public class GeocodingLocation {
  private double latitude;
  private double longitude;
  private String streetName;
  private String streetNumber;
  private Long id;
  private String neighbourhood;

  public GeocodingLocation(double latitude, double longitude, String streetName, String number) {
    this.latitude = latitude;
    this.longitude = longitude;
    this.streetName = streetName;
    this.streetNumber = number;
  }

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public double getLatitude() {
    return latitude;
  }

  public double getLongitude() {
    return longitude;
  }

  public String getStreetName() {
    return streetName;
  }

  public String getStreetNumber() {
    return streetNumber;
  }

  public String getNeighbourhood() {
    return neighbourhood;
  }

  public void setNeighbourhood(String neighbourhood) {
    this.neighbourhood = neighbourhood;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj instanceof GeocodingLocation) {
      GeocodingLocation other = (GeocodingLocation) obj;

      return ((id != null && id.equals(other.id)) ||
              (id == null && other.id == null)) &&
             latitude == other.latitude &&
             longitude == other.longitude &&
             streetName.equals(other.streetName) &&
             streetNumber.equals(other.streetNumber) &&
             neighbourhood.equals(other.neighbourhood);
    }
    else {
      return false;
    }
  }

  @Override
  public int hashCode() {
    return (this.streetName + "-" + this.streetNumber + "-" + this.id).hashCode();
  }
}
